﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;

namespace WindowsGame1
{
    class Projectile : CollidableObject
    {
        int lifespan;
        double spawnTime;
        float mScale = 1.0f;

        public string AttackAssetName = "SwordSlash";
        public Texture2D mProjectileTexture;
        public Vector2 mPosition;

        public Rectangle HitBox;

        Boolean alive = true;

        public Projectile()
        {
            lifespan = 90;
            spawnTime = 0.0;
            mPosition = new Vector2(0, 0);
        }

        internal override void Draw(GameTime gameTime, SpriteBatch spriteBatch)
        {
            spriteBatch.Draw(mProjectileTexture, mPosition, Color.White);
        }

        //Load the texture for the sprite using the Content Pipeline
        internal override void LoadContent(ContentManager theContentManager)
        {
            mProjectileTexture = theContentManager.Load<Texture2D>(AttackAssetName);
            HitBox = new Rectangle(0, 0, (int)(mProjectileTexture.Width * mScale), (int)(mProjectileTexture.Height * mScale));
        }

        //Update the Sprite and change it's position based on the passed in speed, direction and elapsed time.
        internal override void Update(GameTime gameTime)
        {
            HitBox.Location = new Point((int)mPosition.X, (int)mPosition.Y);
            if ((gameTime.TotalGameTime.TotalMilliseconds - spawnTime > lifespan))
            {
                alive = false;
            }
        }

        internal override Rectangle GetHitBox()
        {
            return HitBox;
        }

        internal override Boolean IsAlive()
        {
            return (alive);
        }

        public void SetPosition(Vector2 position)
        {
            mPosition = position;
        }

        public Point GetPosition()
        {
            return new Point((int)mPosition.X, (int)mPosition.Y);
        }
    }

    enum ProjectileType
    {

    }
}
